package cn.tedu.front.search.startup;

import cn.tedu.front.search.service.ICompanyService;
import cn.tedu.front.search.service.IDistrictService;

import cn.tedu.front.search.service.IJobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

@Component
public class CustomRunner implements ApplicationRunner {

    @Autowired
    private IDistrictService districtService;
    @Autowired
    private ICompanyService companyService;
    @Autowired
    private IJobService jobService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        System.out.println("通过缓存预热的方法，将MySQL中的省市区数据加载到Redis缓存中……");
        districtService.rebuildCache();

        System.out.println("通过缓存预热的方法，将MySQL中的公司数据加载到ElasticSearch中……");
        companyService.saveCompany();

        System.out.println("通过缓存预热的方法，将MySQL中的工作数据加载到ElasticSearch中……");
        jobService.saveJob();
    }

}
